<?php

/*
	Class: App_View_Smarty

	About: Author
		J. William McCarthy

	About: License
		<http://communit.as/docs/license>

*/

class App_View_Smarty extends Smarty{
	
	
	function _smarty_include($params){
		
		$theme_global = Zend_Registry::get('theme_global_path');
		$default_global = Zend_Registry::get('default_global_path');
		
		$file = substr( $params['smarty_include_tpl_file'], strlen("file:") );	
		
		if(!file_exists($file)){
			$params['smarty_include_tpl_file'] = str_replace($theme_global,$default_global,$params['smarty_include_tpl_file']);			
		}
		
		$file = substr( $params['smarty_include_tpl_file'], strlen("file:") );
		
		if(!file_exists($file)){
			throw new Exception("MISSING_TEMPLATE - The template file does not exist: " . $file );
		}
				
		return parent::_smarty_include($params);
	}
	
	
}